#include "Gui.h"

#include <string>

#include <cv.h>
#include <highgui.h>

#include <niftout/Output.h>

#include "Controller.h"

Gui::Gui(Controller* controller)
{
	this->controller = controller;
	
	this->mainWindowName = "Input Image";
	
	cvNamedWindow(this->mainWindowName.c_str(), CV_WINDOW_AUTOSIZE);
	
	cvWaitKey(50); //this is needed to give the application some time to create the window
	
}

Gui::~Gui()
{
}

void Gui::displayFrame(IplImage* image){
	
	char key;
	
	cvShowImage(this->mainWindowName.c_str(), image);
	key = cvWaitKey(5); //this is needed to give the application some time to update the window
	if (key == 'q'){
		Output::message("Shutting down...", Output::VERBOSE);
		cvDestroyWindow(this->mainWindowName.c_str());
		this->controller->shutDown();
		
	}
	
}

